<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>三角形最小路径和</title>
</head>

<body>
  <script>
    function arr(num) {
      for (let i = num.length - 2; i >= 0; i--) {
        for (let j = 0; j < num[i].length; j++) {
          num[i][j] += Math.min(num[i + 1][j], num[i + 1][j + 1])
        }
      }
      return num[0][0]
    }
    console.log(arr([[2], [3, 4], [6, 5, 7], [4, 1, 8, 3]]));
  </script>
</body>

</html>